package priv.conceit.sc.hoxton.common.util;

import java.text.ParseException;
import java.time.*;
import java.time.chrono.IsoChronology;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;

/**
 * 时间日期处理工具
 *
 * @author: conceit
 * @Date: 2018/10/11 0011 14:49
 */
public class DateTimeUtil {


	public enum FormatEnum {
		yyyy年MM月dd日("yyyy年MM月dd日"),
		yyyy横杠MM("yyyy-MM"),
		yyyy横杠MM横杠dd("yyyy-MM-dd"),
		yyyy斜杠MM("yyyy/MM"),
		yyyyMMdd("yyyyMMdd"),
		yyyyMM("yyyyMM"),
		yyyy年MM月("yyyy年MM月"),
		yyyy斜杠MM斜杠dd空格HH冒号mm冒号ss("yyyy/MM/dd HH:mm:ss"),
		yyyy年MM月dd日空格HH冒号mm冒号ss("yyyy年MM月dd日 HH:mm:ss"),
		yyyy年MM月dd日空格HH时mm分ss秒("yyyy年MM月dd日 HH时mm分ss秒"),
		yyyy年MM月dd日空格HH时mm分ss秒SSS毫秒("yyyy年MM月dd日 HH时mm分ss秒SSS毫秒"),
		yyyy年MM月dd日空格HH时mm分("yyyy年MM月dd日 HH时mm分"),
		yyyy横杠MM横杠dd空格HH冒号mm("yyyy-MM-dd HH:mm"),
		yyyy年横杠月横杠日空格HH冒号mm冒号ss("yyyy-MM-dd HH:mm:ss"),
		HH冒号mm冒号ss("HH:mm:ss");

		public String value;

		public String getValue() {
			return value;
		}

		FormatEnum(String value) {
			this.value = value;
		}
	}

	/**
	 * convertTimestampToLocalDateTime 转换时间戳为LocalDateTime
	 *
	 * @param timestamp
	 * @return java.time.LocalDateTime
	 * @author conceit
	 * @date 2020/12/11 15:05
	 */
	public static LocalDateTime convertTimestampToLocalDateTime(Long timestamp){
		return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
	}

	/**
	 * convertTimestampToLocalDateTime 转换LocalDateTime为时间戳
	 *
	 * @param localDateTime
	 * @return java.time.LocalDateTime
	 * @author conceit
	 * @date 2020/12/11 15:05
	 */
	public static Long convertLocalDateTimeToTimestamp(LocalDateTime localDateTime){
		return localDateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
	}


	/**
	 * convertDateToLocalDateTime Date转换为LocalDateTime
	 *
	 * @params [date]
	 * @author: conceit
	 * @return: java.time.LocalDateTime
	 * @Date: 2018/10/11 0011 18:21
	 */
	public static LocalDateTime convertDateToLocalDateTime(Date date) {
		return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
	}

	/**
	 * convertLocalDateTimeToDate LocalDateTime转换为Date
	 *
	 * @params [localDateTime]
	 * @author: conceit
	 * @return: java.util.Date
	 * @Date: 2018/10/11 18:21
	 */
	public static Date convertLocalDateTimeToDate(LocalDateTime localDateTime) {
		return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
	}

	/**
	 * convertLocalDateToDate LocalDate转换为Date
	 *
	 * @param localDate
	 * @return java.util.Date
	 * @author conceit
	 * @date 2020/3/24 9:48
	 */
	private static Date convertLocalDateToDate(LocalDate localDate) {
		ZonedDateTime zonedDateTime = localDate.atStartOfDay(ZoneId.systemDefault());
		return Date.from(zonedDateTime.toInstant());
	}

	/**
	 * convertLocalDateToLocalDateTime  LocalDate转换为LocalDateTime
	 *
	 * @param localDate
	 * @return java.time.LocalDateTime
	 * @author conceit
	 * @date 2020/3/24 9:51
	 */
	private static LocalDateTime convertLocalDateToLocalDateTime(LocalDate localDate) {
		return LocalDateTime.of(localDate,LocalTime.MIN);
	}

	/**
	 * convertLocalDateToLocalDateTime  LocalDateTime转换为LocalDate
	 *
	 * @param localDateTime
	 * @return java.time.LocalDateTime
	 * @author conceit
	 * @date 2020/3/24 9:51
	 */
	private static LocalDate convertLocalDateTimeToLocalDate(LocalDateTime localDateTime) {
		return localDateTime.toLocalDate();
	}


	/**
	 * getCurrentDayStartTime 获取参数天数的零点时间
	 *
	 * @params [localDateTime]
	 * @author: conceit
	 * @return: java.time.LocalDateTime
	 * @Date: 2018/10/11 18:22
	 */
	public static LocalDateTime getDayStartTime(LocalDateTime localDateTime) {
		return localDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
	}

	public static Date getDayStartTime(Date date) {
		return convertLocalDateTimeToDate(getDayStartTime(convertDateToLocalDateTime(date)));
	}

	/**
	 * getCurrentDayStartTime 获取当前天的起始时间
	 *
	 * @param
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/11/29 10:53
	 */
	public static LocalDateTime getCurrentDayStartTime() {
		return getDayStartTime(LocalDateTime.now());
	}

	/**
	 * getCurrentDayStartTimes 获取当前天的起始时间
	 *
	 * @param
	 * @return: java.util.Date
	 * @author: conceit
	 * @date: 2019/11/29 10:53
	 */
	public static Date getCurrentDayStartTimes() {
		return convertLocalDateTimeToDate(getDayStartTime(LocalDateTime.now()));
	}


	/**
	 * getCurrentDayEndTime 获取参数天数的最后时间
	 *
	 * @params [localDateTime]
	 * @author: conceit
	 * @return: java.time.LocalDateTime
	 * @Date: 2018/10/11 18:22
	 */
	public static LocalDateTime getDayEndTime(LocalDateTime localDateTime,boolean withNano) {
		if(withNano){
			return localDateTime.with(LocalTime.MAX);
		}else{
			return localDateTime.withHour(23).withMinute(59).withSecond(59);
		}
	}

	/**
	 * getDayEndTime 获取指定天的最后时刻
	 *
	 * @param date
	 * @param withNano 是否需要指定到nano mysql dataTime有时 23:59:59.999 会进到下一天
	 * @return java.util.Date
	 * @author conceit
	 * @date 2020/3/23 17:42
	 */
	public static Date getDayEndTime(Date date,boolean withNano) {
		return convertLocalDateTimeToDate(getDayEndTime(convertDateToLocalDateTime(date),withNano));
	}


	/**
	 * isSameDay 两个形参是否是同一天
	 *
	 * @params [localDateTime1, localDateTime2]
	 * @author: conceit
	 * @return: boolean
	 * @Date: 2018/10/11 18:23
	 */
	public static boolean isSameDay(LocalDateTime localDateTime1, LocalDateTime localDateTime2) {
		if (localDateTime1.toLocalDate().toEpochDay() - localDateTime2.toLocalDate().toEpochDay() == 0) {
			return true;
		}
		return false;
	}

	/**
	 * isSameDay 两个形参是否是同一天
	 *
	 * @params [localDateTime1, localDateTime2]
	 * @author: conceit
	 * @return: boolean
	 * @Date: 2018/10/11 0011 18:23
	 */
	public static boolean isSameDay(Date date1, Date date2) {

		if (convertDateToLocalDateTime(date1).toLocalDate().toEpochDay() - convertDateToLocalDateTime(date2).toLocalDate().toEpochDay() == 0) {
			return true;
		}
		return false;
	}

	/**
	 * getApartDay 两个形参相差的天数(自然天)。var2-var1
	 *
	 * @params [localDateTime1, localDateTime2]
	 * @author: conceit
	 * @return: long
	 * @Date: 2018/10/11 0011 18:24
	 */
	public static long getApartDay(LocalDateTime localDateTime1, LocalDateTime localDateTime2) {
		return (localDateTime2.toLocalDate().toEpochDay() - localDateTime1.toLocalDate().toEpochDay());
	}

	/**
	 * getApartDay 两个形参相差的天数(自然天)。var2-var1
	 *
	 * @params [localDateTime1, localDateTime2]
	 * @author: conceit
	 * @return: long
	 * @Date: 2018/10/11 0011 18:24
	 */
	public static long getApartDay(Date date1, Date date2) {
		return convertDateToLocalDateTime(date2).toLocalDate().toEpochDay() - convertDateToLocalDateTime(date1).toLocalDate().toEpochDay();
	}

	/**
	 * format 将date按照指定格式进行格式化
	 *
	 * @params [Date, format]
	 * @author: conceit
	 * @return: java.lang.String
	 * @Date: 2018/10/12 0012 18:05
	 */
	public static String format(Date Date, String format) {
		return convertDateToLocalDateTime(Date).format(DateTimeFormatter.ofPattern(format));
	}

	/**
	 * format 将时间戳按照指定格式进行格式化
	 *
	 * @params timestamp
	 * @params format
	 * @author: conceit
	 * @return: java.lang.String
	 * @Date: 2020/12/11  15:05
	 */
	public static String format(Long timestamp, String format) {
		return convertTimestampToLocalDateTime(timestamp).format(DateTimeFormatter.ofPattern(format));
	}

	/**
	 * format 将localDateTime按照指定格式进行格式化
	 *
	 * @params [localDateTime, format]
	 * @author: conceit
	 * @return: java.lang.String
	 * @Date: 2018/10/12 0012 18:05
	 */
	public static String format(LocalDateTime localDateTime, String format) {
		return localDateTime.format(DateTimeFormatter.ofPattern(format));
	}

	/**
	 * parseLocalDateTime 将已经格式化的时间字符串，按照指定的格式，进行解析，返回LocalDateTime
	 *
	 * @params [timeText, format]
	 * @author: conceit
	 * @return: java.time.LocalDateTime
	 * @Date: 2018/10/12 0012 18:06
	 */
	public static LocalDateTime parseLocalDateTime(String timeText, String format) {
		return LocalDateTime.parse(timeText, DateTimeFormatter.ofPattern(format));
	}

	/**
	 * parseLocalDate 将已经格式化的时间字符串，按照指定的格式，进行解析，返回LocalDate
	 * LocalDate接受到天
	 *
	 * @param timeText
     * @param format
	 * @return java.time.LocalDate
	 * @author conceit
	 * @date 2020/8/24 17:33
	 */
	public static  LocalDate parseLocalDate(String timeText, String format){
		return LocalDate.parse(timeText, DateTimeFormatter.ofPattern(format));
	}

	/**
	 * parseDate arseLocalDateTime 将已经格式化的时间字符串，按照指定的格式，进行解析，返回Date
	 * 如果timeText 为localDate型 即只指定到天 使用该方法会异常 更新为DateTimeParseException用LocalDate再解析一次
	 * @params [timeText, format]
	 * @author: conceit
	 * @return: java.util.Date
	 * @Date: 2018/10/12 0012 18:07
	 */
	public static Date parseDate(String timeText, String format) {
		LocalDateTime localDateTime=null;
		try{
			localDateTime=LocalDateTime.parse(timeText, DateTimeFormatter.ofPattern(format));
		}catch (DateTimeParseException dateTimeParseException){
			LocalDate localDate=LocalDate.parse(timeText, DateTimeFormatter.ofPattern(format));
			return convertLocalDateToDate(localDate);
		}
		return convertLocalDateTimeToDate(localDateTime);
	}




	/**
	 * 某日期加上几天
	 *
	 * @param date
	 * @param day
	 * @return
	 * @throws ParseException
	 */
	public static Date addDate(Date date, long day) throws ParseException {
		long time = date.getTime(); // 得到指定日期的毫秒数
		day = day * 24 * 60 * 60 * 1000; // 要加上的天数转换成毫秒数
		time += day; // 相加得到新的毫秒数
		return new Date(time); // 将毫秒数转换成日期
	}

	public static Date getBeforeOrAfterMonth(Date date, int num) {
		Calendar calendar = Calendar.getInstance();//获取日历
		calendar.setTime(date);//当date的值是当前时间，则可以不用写这段代码。
		calendar.add(Calendar.MONTH, num);
		Date d = calendar.getTime();//把日历转换为Date
		return d;
	}

	public static Date getBeforeOrAfterDate(Date date, int num) {
		Calendar calendar = Calendar.getInstance();//获取日历
		calendar.setTime(date);//当date的值是当前时间，则可以不用写这段代码。
		calendar.add(Calendar.DATE, num);
		Date d = calendar.getTime();//把日历转换为Date
		return d;
	}

	/**
	 * 计算两个时间差
	 */
	public static String getDatePoor(Date endDate, Date nowDate) {
		long nd = 1000 * 24 * 60 * 60;
		// 获得两个时间的毫秒时间差异
		long diff = endDate.getTime() - nowDate.getTime();
		// 计算差多少天
		long day = diff / nd;
		return day + "天";
	}

	public static LocalDateTime addNano(LocalDateTime localDateTime, long nanos) {
		return localDateTime.plusNanos(nanos);
	}

	public static LocalDateTime addSecond(LocalDateTime localDateTime, long seconds) {
		return localDateTime.plusSeconds(seconds);
	}

	public static LocalDateTime addMinute(LocalDateTime localDateTime, long minutes) {
		return localDateTime.plusMinutes(minutes);
	}

	public static LocalDateTime addHour(LocalDateTime localDateTime, long hours) {
		return localDateTime.plusHours(hours);
	}

	public static LocalDateTime addDay(LocalDateTime localDateTime, long days) {
		return localDateTime.plusDays(days);
	}

	public static LocalDateTime addWeek(LocalDateTime localDateTime, long weeks) {
		return localDateTime.plusWeeks(weeks);
	}

	public static LocalDateTime addMonth(LocalDateTime localDateTime, long months) {
		return localDateTime.plusMonths(months);
	}

	public static LocalDateTime addYear(LocalDateTime localDateTime, long years) {
		return localDateTime.plusYears(years);
	}

	public static LocalDateTime minusNano(LocalDateTime localDateTime, long nanos) {
		return localDateTime.minusNanos(nanos);
	}

	public static LocalDateTime minusSecond(LocalDateTime localDateTime, long seconds) {
		return localDateTime.minusSeconds(seconds);
	}

	public static LocalDateTime minusMinute(LocalDateTime localDateTime, long minutes) {
		return localDateTime.minusMinutes(minutes);
	}

	public static LocalDateTime minusHour(LocalDateTime localDateTime, long hours) {
		return localDateTime.minusHours(hours);
	}

	public static LocalDateTime minusDay(LocalDateTime localDateTime, long days) {
		return localDateTime.minusDays(days);
	}

	public static LocalDateTime minusWeek(LocalDateTime localDateTime, long weeks) {
		return localDateTime.minusWeeks(weeks);
	}

	public static LocalDateTime minusMonth(LocalDateTime localDateTime, long months) {
		return localDateTime.minusMonths(months);
	}

	public static LocalDateTime minusYear(LocalDateTime localDateTime, long years) {
		return localDateTime.minusYears(years);
	}


	public static Date addNano(Date date, long nanos) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusNanos(nanos));
	}

	public static Date addSecond(Date date, long seconds) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusSeconds(seconds));
	}

	public static Date addMinute(Date date, long minutes) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusMinutes(minutes));
	}

	public static Date addHour(Date date, long hours) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusHours(hours));
	}

	public static Date addDay(Date date, long days) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusDays(days));
	}

	public static Date addWeek(Date date, long weeks) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusWeeks(weeks));
	}

	public static Date addMonth(Date date, long months) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusMonths(months));
	}

	public static Date addYear(Date date, long years) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).plusYears(years));
	}

	public static Date minusNano(Date date, long nanos) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusNanos(nanos));
	}

	public static Date minusSecond(Date date, long seconds) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusSeconds(seconds));
	}

	public static Date minusMinute(Date date, long minutes) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusMinutes(minutes));
	}

	public static Date minusHour(Date date, long hours) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusHours(hours));
	}

	public static Date minusDay(Date date, long days) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusDays(days));
	}

	public static Date minusWeek(Date date, long weeks) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusWeeks(weeks));
	}

	public static Date minusMonth(Date date, long months) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusMonths(months));
	}

	/**
	 * 指定时间减去指定年数
	 *
	 * @param date
	 * @param years
	 * @return
	 */
	public static Date minusYear(Date date, long years) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).minusYears(years));
	}

	public static Integer getCurrentTimeSec() {
		return Long.valueOf(System.currentTimeMillis() / 1000).intValue();
	}


	/**
	 * 获取指定时间是该周的第几天
	 *
	 * @param date
	 * @return
	 */
	public static int getDayOfWeek(Date date) {
		return convertDateToLocalDateTime(date).getDayOfWeek().getValue();
	}

	/**
	 * 获取指定时间是月的第几天
	 *
	 * @param date
	 * @return
	 */
	public static int getDayOfMonth(Date date) {
		return convertDateToLocalDateTime(date).getDayOfMonth();
	}

	/**
	 * 获取指定时间的总天数
	 *
	 * @param date
	 * @return
	 */
	public static int countDayInMonth(Date date) {
		return convertDateToLocalDateTime(date).getMonth().length(Year.isLeap(convertDateToLocalDateTime(date).getYear()));
	}

	/**
	 * isInterval 比较是否在指定的时间段内
	 *
	 * @param in 原始值
  	 * @param start 起始时间
	 * @param end	结束时间
	 * @return int -1 小于指定的时间段，0 在指定的时间段内 ，1大于指定的时间段
	 * @author conceit
	 * @date 2020/9/2 11:05
	 */
	public static int isInterval(LocalDateTime in,LocalDateTime start,LocalDateTime end){
		if(Objects.isNull(in)){
			in=LocalDateTime.now();
		}
		if(Objects.isNull(start)){
			start=LocalDateTime.now();
		}
		if(Objects.isNull(end)){
			end=LocalDateTime.now();
		}
		//如果end 小于start则将两方调换
		if(start.compareTo(end)==1){
			LocalDateTime temp=start;
			start=end;
			end=temp;
		}

		int compare=0;
		if(in.compareTo(start)==-1){
			compare=-1;
		}else if(in.compareTo(end)==1){
			compare=1;
		}
		return compare;
	}
	/**
	 * 获取指定时间 月的第一天
	 *
	 * @param date
	 * @return
	 */
	public static Date getFirstDayOfMonth(Date date) {
		return convertLocalDateTimeToDate(convertDateToLocalDateTime(date).withDayOfMonth(1));
	}


	/**
	 * 获取指定时间的 年份
	 *
	 * @param date
	 * @return
	 */
	public static int getYear(Date date) {
		return convertDateToLocalDateTime(date).getYear();
	}

	/**
	 * 获取指定时间的 小时
	 *
	 * @param date
	 * @return
	 */
	public static int getHour(Date date) {
		return convertDateToLocalDateTime(date).getHour();
	}

	/**
	 * 获取指定时间的 分钟
	 *
	 * @param date
	 * @return
	 */
	public static int getMinute(Date date) {
		return convertDateToLocalDateTime(date).getMinute();
	}

	/**
	 * 获取指定时间的 月
	 *
	 * @param date
	 * @return
	 */
	public static int getMonth(Date date) {

		return convertDateToLocalDateTime(date).getMonth().getValue();
	}

	/**
	 * getZeroDateTime 获取指定年月日的 零点时间 例如2019-01-01T00:00
	 *
	 * @param year
	 * @param month
	 * @param day
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/12/5 11:35
	 */
	public static LocalDateTime getZeroDateTime(int year, int month, int day) {
		LocalDate localDateYearZero = LocalDate.of(year, month, day);
		LocalTime localTimeYearZero = LocalTime.MIN;
		return LocalDateTime.of(localDateYearZero, localTimeYearZero);
	}

	/**
	 * getZeroDateTime 获取指定年月的 零点时间 例如2019-01-01T00:00
	 * 不传入day 则获取 月 的第一天
	 *
	 * @param year
	 * @param month
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/12/5 11:35
	 */
	public static LocalDateTime getZeroDateTime(int year, int month) {
		LocalDate localDateYearZero = LocalDate.of(year, month, 1);
		LocalTime localTimeYearZero = LocalTime.MIN;
		return LocalDateTime.of(localDateYearZero, localTimeYearZero);
	}

	/**
	 * getZeroDateTime 获取指定年月的 零点时间 例如2019-01-01T00:00
	 * month 则获取1月
	 * 不传入day 则获取 月 的第一天
	 *
	 * @param year
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/12/5 11:35
	 */
	public static LocalDateTime getZeroDateTime(int year) {
		LocalDate localDateYearZero = LocalDate.of(year, 1, 1);
		LocalTime localTimeYearZero = LocalTime.MIN;
		return LocalDateTime.of(localDateYearZero, localTimeYearZero);
	}

	/**
	 * getTerminusDateTime 获取指定年月日的 终点时间 例如2019-10-31T23:59:59.999999999
	 *
	 * @param year
	 * @param month
	 * @param day
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/12/5 11:40
	 */
	public static LocalDateTime getTerminusDateTime(int year, int month, int day) {
		LocalDate localDateYearEnd = LocalDate.of(year, month, day);
		LocalTime localTimeYearEnd = LocalTime.MAX;
		return LocalDateTime.of(localDateYearEnd, localTimeYearEnd);
	}

	/**
	 * getTerminusDateTime 获取指定年月的 终点时间 例如2019-10-31T23:59:59.999999999
	 * 不传入day 则计算指定月的最后一天
	 *
	 * 如果是闰2月 则具体判断
	 * @param year
	 * @param month
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/12/5 11:40
	 */
	public static LocalDateTime getTerminusDateTime(int year, int month) {
		boolean isLeapYear=IsoChronology.INSTANCE.isLeapYear(year);
		boolean isFebruary=month==2;
		LocalDate localDateYearEnd ;
		if(isLeapYear&&isFebruary){
			localDateYearEnd=LocalDate.of(year, Month.of(month),29);
		}else{
			if(isFebruary){
				localDateYearEnd=LocalDate.of(year, Month.of(month),28);
			}else{
				localDateYearEnd=LocalDate.of(year, Month.of(month),Month.of(month).maxLength());
			}
		}

		//获取指定年的指定月的最后一天的23点59分59秒59毫秒9999纳秒
		LocalTime localTimeYearEnd = LocalTime.MAX;
		return LocalDateTime.of(localDateYearEnd, localTimeYearEnd);
	}



	/**
	 * getTerminusDateTime 获取指定年的 终点时间 例如2019-10-31T23:59:59.999999999
	 * 不传入month 则计算指定年的最后一天
	 *
	 * @param year
	 * @return: java.time.LocalDateTime
	 * @author: conceit
	 * @date: 2019/12/5 11:40
	 */
	public static LocalDateTime getTerminusDateTime(int year) {
		LocalDate localDateYearEnd = LocalDate.of(year, Month.DECEMBER, Month.DECEMBER.maxLength());
		LocalTime localTimeYearEnd = LocalTime.MAX;
		return LocalDateTime.of(localDateYearEnd, localTimeYearEnd);
	}


}
